import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;


public class Test {

    //3.11
    //使用Scanner实现浮点型输入，其整数部分输出；
//    public static void main1(String[] args) {
//
//        Scanner scanner = new Scanner(System.in);
//
//        double a = scanner.nextDouble();
//        int b = (int)a;
//        System.out.println(b);
//    }


//    public static void main2(String[] args) {
//
//        BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
//
//        String str = buf.readLine();
//        float num = Float.parseFloat(str);
//
//        System.out.println(num);
//    }



    //3.12
//    public static void main3(String[] args) {
//
//        int a = 0;
//        double b = 0;
//
//        Scanner sc1 = new Scanner(System.in);
//        //Scanner sc2 = new Scanner(System.in);
//
//        a = sc1.nextInt();
//        b = sc1.nextDouble();
//
//        double d = a / b;
//
//        System.out.println(d);
//
//    }


    //3.13
//    public static void main4(String[] args) {
//
//        Scanner sc2 = new Scanner(System.in);
//
//        double r = sc2.nextDouble();
//        double h = sc2.nextDouble();
//
//        System.out.println(r*r*h*3.14);
//
//    }



    //1.
    public static void main4(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println("请输入第一个数：");
        double a = sc.nextDouble();

        System.out.println("请输入第二个数：");
         double b = sc.nextDouble();

        System.out.println("请输入运算符：+，—，*，/");

        // charAt()作用是返回字符串中指定位置的字符；
        char c = sc.next().charAt(0);

//        if(c == '*'){
//
//            System.out.printf("%f * %f = %.2f", a, b, a*b);
//        }else if(c == '+') {
//
//            //加号的特别
//            System.out.printf("%f + %f = %.2f", a, b, a+b);
//        }else if(c == '-') {
//
//            System.out.printf("%f - %f = %.2f", a, b, a-b);
//        }else {
//
//            System.out.printf("%f / %f = %.2f", a, b, a/b);
//        }
//

        switch(c) {
            case '*':
                System.out.printf("%f * %f = %.2f", a, b, a*b);
                break;

            case '-':
                System.out.printf("%f - %f = %.2f", a, b, a-b);
                break;

            case '+':
                System.out.printf("%f + %f = %.2f", a, b, a+b);
                break;

            case '/':
                System.out.printf("%f / %f = %.2f", a, b, a/b);
                break;

        }

    }





    //2.
    public static void main5(String[] args) {

        System.out.println("请输入a, b, c的值：");
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();


        double delta = b*b-4*a*c;
        System.out.println("delta = "+delta);

        double x1 = (-b + Math.sqrt(delta)) / 2*a;
        double x2 = (-b - Math.sqrt(delta)) / 2*a;
        System.out.println("有两个不等的实根");
        System.out.println("x1 = " + x1);
        System.out.println("x2 = " + x2);

    }





    //3.
    public static void main6(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数：");

        double num = sc.nextDouble();
        double a = 0;
        double b = 1;
        double sum = 1;
        while(true){

            if( num > b ){
                a = b;
                b = sum;
                sum = a + b;
            }else if(num == b){
                System.out.println("true");
                break;
            }else{
                System.out.println("false");
                break;
            }
        }
    }


    //4.
    public static void main7(String[] args) {

        for(int i = 1; i <= 9; i++) {

            for (int j = 1; j <= i; j++) {

                System.out.print(i + "*" + j + "=" + " " + i*j + " ");
            }

            System.out.println();
        }
    }


    //5.
    static String func(int a){

        if(a == 0){
            return "";
        }else if(a == 1){
            return "1";
        }else {
            return func(a/2) + (a % 2) + "";
        }
    }


    public static void main8(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数:");
        int a = sc.nextInt();

        System.out.print(a + "的二进制为:");
        String number = func(a);
        System.out.println(number);

    }

    //4.8
    public static void main9(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个你认为可能是完全数的数：");
        int a = sc.nextInt();

        int sum = 1;
        for(int i = 2; i <= Math.sqrt(a); i++) {

            int b = a;
            if(b % i == 0){
                sum += i;
                sum += (b/i);
            }else {
                continue;
            }

        }
        if( sum == a) {

            System.out.println(a + "是完全数 ！");
        }
    }



    //4.17
    static int func(int a, int b) {

        if (b == 0) {

            return a;
        }else {
            return func(b, a%b);
        }
    }

    public static void main10(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你想求取最大公约数的两个整数：");
        int a = sc.nextInt();
        int b = sc.nextInt();

        int c = func(a, b);
        System.out.println("上面两个数的最大公约数是" + c);
    }




    //4.18
    static int fun(int a) {

        if(a < 10) {

            return a;
        } else {

            return fun(a/10) + a%10;
        }
    }


    public static void main11(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你想计算的数字：");
        int a = sc.nextInt();

        int c = fun(a);
        System.out.println(a + "的各位数的总和为" + c);
    }





    public static void main12(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String num = Integer.toString(a);
        int length = num.length();

        int sum = 0;
        int a1 = a;
        while( a > 0) {

            int b = a % 10;
            sum += Math.pow( b, length);
            a /= 10;
        }

        if(sum == a1) {

            switch (length) {

                case 1:
                    System.out.println(a1+"是独身数");
                    break;

                case 2:
                    System.out.println(a1+"不存在");
                    break;

                case 3:
                    System.out.println(a1+"是水仙花数");
                    break;

                case 4:
                    System.out.println(a1+"是四叶玫瑰数");
                    break;

                case 5:
                    System.out.println(a1+"是五角星数");
                    break;

                case 6:
                    System.out.println(a1+"是六合数");
                    break;

                case 7:
                    System.out.println(a1+"是北斗七星数");
                    break;

                case 8:
                    System.out.println(a1+"是八仙数");
                    break;

                case 9:
                    System.out.println(a1+"是九九重阳数");
                    break;

                case 10:
                    System.out.println(a1+"是十全十美数");
                    break;
            }
        }

    }





    static int find(int[] arr, int a) {

        int point = 0;
        int length = arr.length;
        int i = 0;
        while(i < length) {

            if(i == length-1) {
                return -10;
            }
            if(arr[i] == a) {
                return i;

            }
            if(arr[i] < a && a < arr[i+1]) {
                return -(i+2);
            }

            i++;
        }
        return 0;
    }

    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int[] arr = new int[]{1, 3, 4, 8, 13, 20, 26, 88, 120};
        System.out.println(Arrays.toString(arr));
        System.out.println("请输入想要插入的数：");
        int a = sc.nextInt();
        int point = find(arr, a);
        System.out.println(point);
    }
}





